home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / dev / sun4c.md / devFsOpTable.c < prev    next >
C/C++ Source or Header  |  1990-11-06  |  7KB  |  237 lines

  1. /* 
  2.  * devFsOpTable.c --
  3.  *
  4.  *    The operation tables for the file system devices on Sun-4 hosts.
  5.  *
  6.  * Copyright 1987, 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/kernel/dev/sun4c.md/RCS/devFsOpTable.c,v 1.4 90/11/06 17:12:22 rab Exp $ SPRITE (Berkeley)";
  18. #endif not lint
  19.  
  20.  
  21. #include "sprite.h"
  22. #include "dev.h"
  23. #include "devInt.h"
  24. #include "fs.h"
  25. #include "rawBlockDev.h"
  26. #include "devFsOpTable.h"
  27. #include "devTypes.h"
  28.  
  29. /*
  30.  * Device specific include files.
  31.  */
  32.  
  33. #include "devSyslog.h"
  34. #include "devNull.h"
  35. #include "devSCSIDisk.h"
  36. #include "devSCSITape.h"
  37. #include "devNet.h"
  38. #include "devBlockDevice.h"
  39. #include "devfb.h"
  40. #include "scsiHBADevice.h"
  41. #include "raidExt.h"
  42. #include "tty.h"
  43. #include "mouse.h"
  44.  
  45.  
  46. static ReturnStatus nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  47.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  48. static ReturnStatus noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  49.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr));
  50. static ReturnStatus nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  51.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr));
  52. static ReturnStatus nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  53.     Fs_IOParam *writePtr, Fs_IOReply *replyPtr));
  54. static ReturnStatus nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  55.     int flags, int numUsers, int numWriters));
  56. static ReturnStatus nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  57.     int *readPtr, int *writePtr, int *exceptPtr));
  58. static ReturnStatus nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  59.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  60. static ReturnStatus noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  61.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr));
  62. static ReturnStatus noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  63.     Address startAddr, int length, int offset, Address *newAddrPtr));
  64.  
  65.  
  66. /*
  67.  * Device type specific routine table:
  68.  *    This is for the file-like operations as they apply to devices.
  69.  *    DeviceOpen
  70.  *    DeviceRead
  71.  *    DeviceWrite
  72.  *    DeviceIOControl
  73.  *    DeviceClose
  74.  *    DeviceSelect
  75.  *    BlockDeviceAttach
  76.  *    DeviceReopen
  77.  *    DeviceMMap
  78.  */
  79.  
  80.  
  81. DevFsTypeOps devFsOpTable[] = {
  82.     /*
  83.      * Serial lines used to implement terminals.
  84.      */
  85.     {DEV_TERM,       DevTtyOpen, DevTtyRead, DevTtyWrite,
  86.              DevTtyIOControl, DevTtyClose, DevTtySelect,
  87.              DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  88.     /*
  89.      * The system error log.  If this is not open then error messages go
  90.      * to the console.
  91.      */
  92.     {DEV_SYSLOG,    Dev_SyslogOpen, Dev_SyslogRead, Dev_SyslogWrite,
  93.             Dev_SyslogIOControl, Dev_SyslogClose, Dev_SyslogSelect,
  94.             DEV_NO_ATTACH_PROC, Dev_SyslogReopen, noMmapProc},
  95.     /*
  96.      * SCSI Worm interface:  this device doesn't exist anymore.
  97.      */
  98.     {DEV_SCSI_WORM, noOpenProc, nullReadProc, nullWriteProc,
  99.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  100.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  101.     /*
  102.      * The following device number is unused.
  103.      */
  104.     {DEV_PLACEHOLDER_2, noOpenProc, nullReadProc, nullWriteProc,
  105.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  106.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  107.     /*
  108.      * New SCSI Disk interface.
  109.      */
  110.     {DEV_SCSI_DISK, DevRawBlockDevOpen, DevRawBlockDevRead,
  111.             DevRawBlockDevWrite, DevRawBlockDevIOControl, 
  112.             DevRawBlockDevClose, nullSelectProc, DevScsiDiskAttach,
  113.             DevRawBlockDevReopen, noMmapProc},
  114.     /*
  115.      * SCSI Tape interface.
  116.      */
  117.     {DEV_SCSI_TAPE, DevSCSITapeOpen, DevSCSITapeRead, DevSCSITapeWrite,
  118.             DevSCSITapeIOControl, DevSCSITapeClose, nullSelectProc,
  119.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  120.     /*
  121.      * /dev/null
  122.      */
  123.     {DEV_MEMORY,    nullOpenProc, Dev_NullRead, Dev_NullWrite,
  124.             Dev_NullIOControl, nullCloseProc, Dev_NullSelect,
  125.             DEV_NO_ATTACH_PROC, nullReopenProc, noMmapProc},
  126.     /*
  127.      * Xylogics 450 disk controller.
  128.      */
  129.     {DEV_XYLOGICS, noOpenProc, nullReadProc, nullWriteProc,
  130.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  131.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  132.     /*
  133.      * Network devices.  The unit number specifies the ethernet protocol number.
  134.      */
  135.     {DEV_NET,      DevNet_FsOpen, DevNet_FsRead, DevNet_FsWrite, 
  136.            DevNet_FsIOControl, DevNet_FsClose, DevNet_FsSelect, 
  137.            DEV_NO_ATTACH_PROC, DevNet_FsReopen, noMmapProc},
  138.     /*
  139.      * Raw SCSI HBA interface.
  140.      */
  141.     {DEV_SCSI_HBA, DevSCSIDeviceOpen, Dev_NullRead, Dev_NullWrite,
  142.             DevSCSIDeviceIOControl, DevSCSIDeviceClose,
  143.             Dev_NullSelect, DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  144.     /*  
  145.      * RAID device.
  146.      */ 
  147.     {DEV_RAID,  noOpenProc, nullReadProc, nullWriteProc,
  148.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  149.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  150.     /*  
  151.      * Debug device. (useful for debugging RAID device)
  152.      */ 
  153.     {DEV_DEBUG, noOpenProc, nullReadProc, nullWriteProc,
  154.             Dev_NullIOControl, nullCloseProc, nullSelectProc,
  155.             DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  156.     /*
  157.      * Event devices for window systems.
  158.      */
  159.     {DEV_MOUSE,    DevMouseOpen, DevMouseRead, DevMouseWrite,
  160.            DevMouseIOControl, DevMouseClose, DevMouseSelect,
  161.            DEV_NO_ATTACH_PROC, noReopenProc, noMmapProc},
  162.     /*
  163.      * Frame buffer device.
  164.      */
  165.     {DEV_GRAPHICS, DevFBOpen, nullReadProc, nullWriteProc,
  166.            DevFBIOControl, DevFBClose, nullSelectProc,
  167.            DEV_NO_ATTACH_PROC, noReopenProc, DevFBMMap},
  168.  
  169. };
  170.  
  171. int devNumDevices = sizeof(devFsOpTable) / sizeof(DevFsTypeOps);
  172.  
  173. static ReturnStatus
  174. nullOpenProc _ARGS_ ((Fs_Device *devicePtr,
  175.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  176. {
  177.     return SUCCESS;
  178. }
  179.  
  180. static ReturnStatus
  181. noOpenProc _ARGS_ ((Fs_Device *devicePtr,
  182.     int flags, Fs_NotifyToken notifyToken, int *flagsPtr))
  183. {
  184.     return FS_INVALID_ARG;
  185. }
  186.  
  187. static ReturnStatus
  188. nullReadProc _ARGS_ ((Fs_Device *devicePtr,
  189.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  190. {
  191.     return SUCCESS;
  192. }
  193.  
  194. static ReturnStatus
  195. nullWriteProc _ARGS_ ((Fs_Device *devicePtr,
  196.     Fs_IOParam *readPtr, Fs_IOReply *replyPtr))
  197. {
  198.     return SUCCESS;
  199. }
  200.  
  201. static ReturnStatus
  202. nullCloseProc _ARGS_ ((Fs_Device *devicePtr,
  203.     int flags, int numUsers, int numWriters))
  204. {
  205.     return SUCCESS;
  206. }
  207.  
  208. static ReturnStatus
  209. nullSelectProc _ARGS_ ((Fs_Device *devicePtr,
  210.     int *readPtr, int *writePtr, int *exceptPtr))
  211. {
  212.     return SUCCESS;
  213. }
  214.  
  215. static ReturnStatus
  216. nullReopenProc _ARGS_ ((Fs_Device *devicePtr,
  217.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  218. {
  219.     return SUCCESS;
  220. }
  221.  
  222. static ReturnStatus
  223. noReopenProc _ARGS_ ((Fs_Device *devicePtr,
  224.     int numUsers, int numWriters, Fs_NotifyToken notifyToken, int *flagsPtr))
  225. {
  226.     return FS_INVALID_ARG;
  227. }
  228.  
  229. static ReturnStatus
  230. noMmapProc _ARGS_ ((Fs_Device *devicePtr,
  231.     Address startAddr, int length, int offset, Address *newAddrPtr))
  232. {
  233.     return FS_INVALID_ARG;
  234. }
  235.  
  236.  
  237.